from Autotests.BaseTest import AirClientTestCase
from Autotests.LocalMachine.Pages.AirClient.OptionsPage.FilterTab import FilterTab


class OptionsFilterTest(AirClientTestCase):
    def setUp(self):
        super(OptionsFilterTest, self).setUp()
        self.filterTab = FilterTab()

    def test_OptionsAddFilter(self):
        self.filterName = '.txt'
        filterCount = self.filterTab.getFilterCount()
        self.filterTab.addFilter(self.filterName)
        self.assertEqual(self.filterTab.getFilterCount(), filterCount + 1, "Filter was added incorrectly")

    def test_OptionsDeleteFilter(self):
        self.filterName = '.FilterForDelete'
        self.filterTab.addFilter(self.filterName)
        filterCount = self.filterTab.getFilterCount()
        self.filterTab.deleteFilter(self.filterName)
        self.assertEqual(self.filterTab.getFilterCount(), filterCount - 1, "Filter was deleted incorrectly")

    def test_OptionsEditFilter(self):
        oldFilterName = '.FilterForEdit'
        self.filterName = '.html'
        self.filterTab.addFilter(oldFilterName)
        filterCount = self.filterTab.getFilterCount()
        self.filterTab.editFilter(oldFilterName, self.filterName)
        self.assertEqual(self.filterTab.getFilterCount(), filterCount, "Filter was edited incorrectly")
        self.assertTrue(self.filterTab.isFilterInList(self.filterName), "Filter wasn't edited")

    def tearDownImpl(self):
        self.filterTab.deleteFilter(self.filterName)

import unittest
if __name__ == "__main__":
    unittest.main()
